<% 
	var headContent = {
	include("/pages/template/head.html"){}
%>

<script type="text/javascript">
		
	var oper;
	jQuery(function($) {
		// 页面方法
		oper = {
			width : 650,
			height : 600,
			form : document.form1,
			list : function() {
				var url = 'admin/site/list';
				this.form.action = url;
				this.form.submit();
			},
			view : function(id) {
				var url = 'admin/site/view/'+id;
				var title = '查看站点';
				Iframe(url, this.width, this.height, title, false, false, false, EmptyFunc);
			},
			add : function() {
				var url = 'admin/site/add';
				var title = '添加站点';
				Iframe(url, this.width, this.height, title);
			},
			edit : function(id) {
				var url = 'admin/site/edit/'+id;
				var title = '修改站点';
				Iframe(url, this.width, this.height, title);
			},
			del : function(id) {
				var url = 'admin/site/delete/'+id;
				var title = '确认要删除该站点信息？';
				Confirm(title, function() {
					form1.action = url;
					form1.submit();
				});
			}
			,setdefault : function(id) {
				var url = 'admin/site/defalut/'+id;
				var title = '确认要设置该站点为默认站点？';
				Confirm(title, function() {
					form1.action = url;
					form1.submit();
				});
			}
		};
		//显示Menu索引
		showMenu('page_site');
	});
	
	//分页
	var paginator = function(page) {
		oper.list();
	};
</script>

<%
};

var bodyContent = {
%>
	<form name="form1" action="" method="post"  class="form-inline" role="form">
		<!-- 菜单 -->
		<% include("/pages/template/menu.html"){} %>
		
		<div class="tableSearch">
			<div class="container">
			<%  //查询列表 %>
			<div class="form-group">
					<input class="form-control" type="text" name="attr.name" value="${attr.name!''}" 
						placeholder="请输入名称" required='required' />
			</div>
			
			<button type="button" class="btn btn-default" onclick="oper.list();" name="search">
			 		<span class="glyphicon glyphicon-search"></span> 查 询
			</button>
			<button type="button" class="btn btn-default" onclick="resetForm();">
			 		<span class="glyphicon glyphicon-refresh"></span> 重 置
			</button>
			<button type="button" class="btn btn-default" onclick="oper.add();">
			 		<span class="glyphicon glyphicon-plus"></span> 新 增
			</button>
			</div>
		</div>


<div class="container" style="margin-top:10px;">
	<div class="row">
    
    <% for(item in page.list){ %>
	<div class="col-sm-4">
		<div class="thumbnail">
			<a href="http://${item.domain_pc}" target="_blank"> 
			<img src="${item.thumbnail!'static/images/video/no_image.jpg'}" height="240" style="height:240px;"
				alt="${item.name}" class="img-responsive">
			</a>
			<div class="caption">
				<h3>${item.name}</h3>
				<p>
						 模板标题：${item.site_title} 
					<br> 模板名称：${item.template} 
					<br> 模板域名：${item.domain_pc}
					<br> 默认模板：
					<% if(item.site_defalut==2) { %><span class="glyphicon glyphicon-remove" style="color: red"></span>
					<a href="javascript:void(0);" onclick="oper.setdefault(${item.id});" style="padding-left:10px;">设置为默认</a>
					<%	} %>
					<% if(item.site_defalut==1) { %><span class="glyphicon glyphicon-ok" style="color: green"></span>
					<%	} %>
					<br> 是否启用：
					<% if(item.status==2) { %><span class="glyphicon glyphicon-remove" style="color: red"></span>
					<%	} %>
					<% if(item.status==1) { %><span class="glyphicon glyphicon-ok" style="color: green"></span>
					<%	} %>
	
				</p>
				<p>
					<a href="javascript:void(0);" class="btn btn-sm btn-success" onclick="oper.view(${item.id});">查看</a> 
					<a href="javascript:void(0);" class="btn btn-sm btn-primary" onclick="oper.edit(${item.id});">修改</a> 
					<a href="javascript:void(0);" class="btn btn-sm btn-danger" onclick="oper.del(${item.id});">删除</a>
				</p>
			</div>
		</div>
	</div>
	<% } %>

	</div>
</div>		


<% /** %>	
		<!-- 数据列表 -->
		<table class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<th>序号</th>
					<%  // 列表头部 %>
					<th name="name" class="sorting">名称</th> 
					<th name="title" class="sorting">标题</th> 
					<th name="template" class="sorting">模板名称</th> 
					<th name="domain_pc" class="sorting">pc端域名</th> 
					<th name="domain_mobile" class="sorting">移动端域名</th> 
					<th name="sort" class="sorting">序号</th> 
					<th name="status" class="sorting">状态</th> 
 					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			<% for(item in page.list){ %>
				<tr>`
				<td>${itemLP.index }</td>
					<%  // 列表内容 %>
					<td>${item.name}(${item.id})</td> 
					<td>${item.site_title}</td>
					<td>${item.template}</td> 
					<td>${item.domain_pc}</td> 
					<td>${item.domain_mobile}</td> 
					<td>${item.sort}</td> 
					<td>
					<% if(item.status==2) { %>
					禁用
					<%	} %>
					<% if(item.status==1) { %>
					启用
					<%	} %>
					</td>  
				<td>
				<a href="javascript:void(0);" class="btn btn-sm btn-success" onclick="oper.view(${item.id});">查看</a> 
				<a href="javascript:void(0);" class="btn btn-sm btn-primary" onclick="oper.edit(${item.id});">修改</a>
				<% if(item.id!=1) { %> 
				<a href="javascript:void(0);" class="btn btn-sm btn-danger" onclick="oper.del(${item.id});">删除</a>
				<% } %>
				</td>
				</tr>
			<% } %>
			</tbody>
		</table>
		<%include("/pages/includes/paginator.html"){} %>
<% **/ %>	
	</form>
<%}; %>


<% layout("/pages/template/_layout.html",{head:headContent,body:bodyContent}){ %>
<%} %>